package main

import (
	"gingorm/framwork"
)

const (
	ServerConfigDirPath = "../config/"
	ServerTemplateDirPath = "../template/"
)

type TestServer struct {
	framwork.Service
	DB	*framwork.ComponentDB
}


// 重写Init函数
func (s *TestServer)Init()error{
	var err error
	// 调用父辈初始化
	err = s.Service.Init()
	if err != nil {
		return err
	}
	// 初始化DB组件
	s.DB = new(framwork.ComponentDB)
	err = s.DB.Init(ServerConfigDirPath + "database.cfg")
	if err != nil {
		return err
	}
	return nil
}

func (s *TestServer) LoadConfig() error {
	s.Engine.LoadHTMLGlob(ServerTemplateDirPath + "*" )
	return nil
}


func (s *TestServer) RegisterRouter(){
	s.RegisterPath("/db", new(CoredataQueryHandle))
	s.RegisterPath("/call", new(ReflectHandle))
	s.RegisterPath("/sky", new(WeatherHandle))
	s.RegisterPath("/infos", new(InfosHandle))
}
